#include"list.h"

void test1()
{
    Mylist::list<int> lt;
    lt.push_back(1);
    lt.push_back(2);
    lt.push_back(3);
    lt.push_back(4);
    lt.push_front(5);
    lt.push_front(6);
    lt.push_front(7);
    lt.push_front(8);
    cout<<lt.size()<<endl;
    Mylist::list<int>::iterator it=lt.begin();
    while(it!=lt.end()){
        cout<<*it<<" ";
        it++;
    }
    cout<<endl;
    lt.pop_back();
    lt.pop_front();
    for(auto e:lt){
        cout<<e<<" ";
    }
    cout<<endl;
    cout<<lt.size()<<endl;
    lt.clear();
    cout<<lt.size()<<endl;

}

void test2(){
    Mylist::list<int> v1;
    v1.push_back(1);
    v1.push_back(2);
    v1.push_back(3);
    v1.push_back(4);
    Mylist::list<int> v2(v1);
    Mylist::list<int> v3;
    v3=v1;
    for(auto e:v2){
        cout<<e<<" ";
    }
    cout<<endl;
    for(auto e:v3){
        cout<<e<<" ";
    }
    cout<<endl;
}

void test3(){
    Mylist::list<Mylist::A> lt;
    lt.push_back(Mylist::A(1,1));
    lt.push_back(Mylist::A(2,2));
    lt.push_back(Mylist::A(3,3));
    lt.push_back(Mylist::A(4,4));
    Mylist::list<Mylist::A>::iterator it=lt.begin();
    while(it!=lt.end()){
        cout<<it->_a1<<","<<it->_a2<<" ";
        it++;
    }
    cout<<endl;
    it=lt.begin();
    while(it!=lt.end()){
        cout<<(*it)._a1<<","<<(*it)._a2<<" ";
        it++;
    }
    cout<<endl;
}

int evalRPN(vector<string>& tokens) {
        stack<int> st;
        auto it=tokens.begin();
        while(it!=tokens.end()){
            string str=*it;
            if(!(str=="+"||str=="*"||str=="/")){
                st.push(atoi(str.c_str()));
            }
            else{
                int right=st.top();
                st.pop();
                int left=st.top();
                st.pop();
                if(str=="+"){
                    st.push(left+right);
                }
                if(str=="*"){
                    st.push(left*right);
                }
                if(str=="/"){
                    st.push(left/right);
                }
            }
            it++;
        }
        return st.top();
    }

int main()
{
    //test1();
    //test2();
    //test3();
    return 0;
}